package day7;

import java.util.Scanner;

/**
 * 机票价格计算
 */
public class CalAirPrice {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入月份");
        int month = sc.nextInt();
        System.out.println("请输入舱位:1，头等舱。2，商务舱。3，经济舱");
        int type = sc.nextInt();
        System.out.println("请输入价格");
        double price = sc.nextDouble();
        double newPrice = newPrice(month, type, price);
        if (newPrice!=-1){
            System.out.println("优惠后的价格为:"+newPrice);
        }


    }

    public static double newPrice(int month,int type,double price){
        double finalPrice =0;
        if (month<1||month>12){
            System.out.println("月份输入错误");
            return -1;
        }
        if (type>3||type<1){
            System.out.println("舱位输入错误");
            return -1;
        }
        if (month>=5&&month<=10){
            switch (type){
                case 1:
                    price*=0.9;
                    break;
                case 2:
                    price*=0.85;
                    break;
                case 3:
                    price*=0.8;
                    break;
                default:
                    System.out.println("输入舱位类型错误");
                    break;
            }
        }else if (month>=11&&month<=12||month>=1&&month<=4){
            switch (type){
                case 1:
                    price*=0.7;
                    break;
                case 2:
                    price*=0.65;
                    break;
                case 3:
                    price*=0.6;
                    break;
                default:
                    System.out.println("输入舱位类型错误");
                    break;
            }
        }
        finalPrice = price;

        return finalPrice;
    }

}

